﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace BusinessIntelligenceToolkit.Demo.Converters
{
    public class WeatherToUrlConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Weather weather = (Weather) value;
            string url;
            switch (weather)
            {
                case Weather.Sunny:
                    url = "pack://application:,,,/BusinessIntelligenceToolkit.Demo;component/Images/Sunny.png";
                    break;
                case Weather.Rainy:
                    url = "pack://application:,,,/BusinessIntelligenceToolkit.Demo;component/Images/Rainy.png";
                    break;
                case Weather.Cloudy:
                    url = "pack://application:,,,/BusinessIntelligenceToolkit.Demo;component/Images/Cloudy.png";
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return new Uri(url);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}